package com.server.thisService.service.impl;

import com.project.thisCommon.model.BaseEntity;
import com.server.thisService.common.convert.SpecificationConvert;
import com.server.thisService.mapper.UserRepository;
import com.server.thisService.model.UserEntity;
import com.server.thisService.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Optional;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserRepository userRepository;

    @Override
    public UserEntity findUserInfo(@RequestBody BaseEntity<UserEntity> en) {
        Specification<UserEntity> findEn = new SpecificationConvert<>(en.getBody());
        Optional<UserEntity> user = userRepository.findOne(findEn);
        return user.get();
    }
}
